<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style type="text/css">
            
            * 
            {
                font-family: "Helvetica Neueu", Helvetica, Arial, sans-serif;
            }
            
            .input 
            {
                font-family: "Helvetica Neueu", Helvetica, Arial, sans-serif;
                font-size: 9pt;
            }
            
            .formField
            {
                width: 500px;
                border: 2px solid #444;
                background-color: #444;
                color: #efefef;
            }
            
            textarea.formField
            {
                height: 250px;
            }
            
            label
            {
                width: 120px;
                font-weight: bold;
                display:block;
            }
            
            select
            {
                width: 250px;
                border: 2px solid #444;
                background-color: #444;
                color: #efefef;
            }
            
            html
            {
                text-align:center;
            }
            
            body 
            {
                width: 500px;
                margin-left:auto;
                margin-right:auto;    
                text-align: left;
            }
            
            
        </style>
        <title>ObjectKit compiler</title>
    </head>
    <body>
        <h1>CompilerService</h1>
        <form action="http://closure-compiler.appspot.com/compile" method="POST" class="input">
            <p>
                <label>
                    Classpath.
                </label>
                <input class="formField" type="text" id="settingClasspath" value="/Asset/Library">
            </p>
            <p>
                <label>
                    Entry class.
                </label>
                <input class="formField" type="text" id="settingEntryClass" value="ie.ondevice.objectkit.compiler.Compiler">
            </p>
            
            <label>Compilation level.</label>
            <select id="settingCompressionLevel">
                <option selected="true" value="NONE">No compression.</option>
                <option value="WHITESPACE_ONLY">Whitespace only.</option>
                <option value="SIMPLE_OPTIMIZATIONS">Simple optimisations.</option>
                <option value="ADVANCED_OPTIMIZATIONS">Advanced optimisations.</option>
            </select>
            <br/>
            <br/>
            <label>Compilation format.</label>
            <select id="settingOutputFormat">
                <option selected="true" value="text">Text</option>
                <option value="json">JSON</option>
                <option value="xml">XML</option>
            </select>            
            
            <br/>

            <br/>
            <!-- -->
            <textarea class="formField" name="js_code" id="js_code" cols="50" rows="5">/* empty */</textarea>
            <input type="hidden" name="compilation_level" id="compilationLevel" value="SIMPLE_OPTIMIZATIONS">
            <!-- format can be json, xml or text -->
            <input type="hidden" name="output_format" id="compilationFormat" value="text">
            <!-- output_info can be compiled_code, warnings, errors or statistics -->
            <input type="hidden" name="output_info" value="statistics">
            <input type="hidden" name="output_info" value="errors">
            <input type="hidden" name="output_info" value="warnings">
            <input type="hidden" name="output_info" value="compiled_code">
            <input type="hidden" name="output_file_name" value="compiled.js">
            <br>
            <br>
            <input type="submit" value="Compile">
            <input type="reset" value="Reset">
        </form>        
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/core.js"></script>  
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/extensions/Array.js"></script>  
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/extensions/String.js"></script>  
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/core.js"></script>  
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/Annotation.js"></script>
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/AnnotationParser.js"></script>
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/ClassPath.js"></script>
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/ClassFile.js"></script>
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/Loader.js"></script>   
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/ClassLoader.js"></script>   
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/CompilerListener.js"></script>
        <script type="text/javascript" src="/Asset/Library/ie/ondevice/objectkit/utility/compiler/Compiler.js"></script>

        <script type="text/javascript">
            
            //alert(location);
            
            /* Compiler Controller */
           
            new function () 
            {
                var form= document.forms[0]
                ,   compiler
                ,   classpath
                ,   entryClass
                ;
                
                
                this.constructor.implement
                (
                    {
                        onFormSubmit: function (submitEvent) 
                        {
                            submitEvent.preventDefault();
                            
                            this.applyOptions();
                            try 
                            {
                                compiler= new Compiler;
                                compiler.setClasspath(classpath);
                                compiler.compile(entryClass);
                                
                            }
                            catch (thrown) 
                            {
                                console.log(thrown.stack || thrown);
                            }
                            finally
                            {
                                console.log('compilation completed');
                            }
                        }
                        
                        
                    ,   applyOptions: function () 
                        {
                            classpath= document.getElementById('settingClasspath').value;
                            entryClass=document.getElementById('settingEntryClass').value;
                            compilationLevel= 'NONE';
                            compilationFormat= 'text';
                        }
                    }
                
                );

                form.addEventListener('submit', this.onFormSubmit.bind(this));
            };
            
            
            
            
            
            
            
            
        </script>
    </body>
</html>
